﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IntelligentRouteAssist
{
    public enum RouteRestPointType
    {
        NoNeed,
        Breakfirst,
        Lunch,
        Tea,
        Dinner
    } 
    public class RouteNode
    {
        public RouteMallObj mall { get; set; }
        public List<RouteStoreObj> stores { get; set; }
        public RouteRestPointType rest { get; set; }
        public ZTimeline startTime { get; set; }
        public ZTimeline endTime { get; set; }
        public RouteNode()
        {
            stores = new List<RouteStoreObj>();
            rest = RouteRestPointType.NoNeed;
        }
        public float CalculateScore()
        {
            float score = mall.mall_score;
            score = score * (1 - (float)Math.Exp(-1 * Math.Sqrt(mall.distanceFromYou)));
            return score;
        }

        public int Duration()
        {
            int duration = 0;
            stores.ForEach(s =>
                {
                    duration += (int)s.duration;
                });
            return (int)(duration * 1.05);
        }

        public void SetEndTime(ZTimeline endTimeLine)
        {
            if (endTime.atHour >= 11 && endTime.atHour <= 13)
            {
                rest = RouteRestPointType.Lunch;
            }
            else if (endTime.atHour >= 14 && endTime.atHour <= 16)
            {
                rest = RouteRestPointType.Tea;
            }
            else if (endTime.atHour >= 18 && endTime.atHour <= 20)
            {
                rest = RouteRestPointType.Dinner;
            }
            this.endTime = endTimeLine;
        }

        public string warning
        {
            get
            {
                if (endTime.overTime)
                {
                    return "可能没有足够的时间";
                }
                else return string.Empty;
            }
        }
    }
}
